<link href="/Static/mobile/css/weui.min.css" rel="stylesheet">
<script type="text/javascript" src="https://res.wx.qq.com/open/libs/weuijs/1.1.3/weui.min.js"></script>
<link rel="stylesheet" href="/Static/mobile/vant/index.css">
<script src="/Static/mobile/vant/vue.min.js"></script>
<script src="/Static/mobile/vant/vant.min.js?i=1"></script>
<style>
    .weui-cells{
        font-size: 13px;
    }
    body{
        padding-bottom: 40px;
    }
</style>
<include file="Common:address"/>
<div id='tihuoapp' class='page'>
    <div class="weui-cells__title">提货商品</div>
    <div class="weui-cells weui-cells_radio">
        <template  v-for="item in list">
            <van-cell-group>
                <van-cell>
                    <span slot="title" style="font-size:15px;">{{item.goods_name}}
                        <van-stepper min="0" style="position:absolute;right:10px;bottom:10px;font-size:15px;" v-model="item.num" ></van-stepper>
                    </span>
                    <img slot="icon" width="80" height="80" :src="item.goods_pic"/>
                </van-cell>
            </van-cell-group>
        </template>
    </div> 
     

   
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p>可提货库存</p>
            </div>
            <div class="weui-cell__ft"><?=$memberinfo['stock']?></div>
        </div>
    </div>
    <div style='padding:20px 15px;'>
        <a @click='addOrder'  class="weui-btn weui-btn_primary">提交</a>
    </div>
</div>

<include file="Common:nav" />
<script src="__STATIC__mobile/js/areadata.js"></script>
<script src="__STATIC__mobile/js/myarea.js"></script>
<script>
    var tihuoapp = new Vue({
        el: '#tihuoapp',
        data: {
            order: {
                order_type: 3,
            },
            list:[],
            smstext:'获取验证码'
        },
        mounted: function () {
        },
        created: function () {
            var self = this;
            $.get('/mobile/cart/getGoodsList?grade=2').then(function(res){
                if(res.ret==0) {
                    self.list = [];
                    for(var i=0;i<res.data.length;i++) {
                        self.list.push(res.data[i]);
                    }
                }else{
                    self.list = [];
                }
            })
        },
        methods: {
            addOrder: function () {
                var self = this;
                self.order.goodslist = self.list;
                self.order.address_id = addressapp.chosenAddressId;
                var cfm = weui.confirm('确定提交订单吗?',function(){
                    var loading = weui.loading('loading');
                    $.ajax({
                        url:'/mobile/orderadd/tihuo',
                        data: self.order,
                        type:'post'
                    }).then(function(res){
                        loading.hide();
                        if(res.ret==1) {
                            showerror(res.msg);
                        }else if(res.ret==0){
                            showsuccess(res.msg,res.url);
                        }
                    });
                })
            },
            getsmscode: function () {
                AjaxUrl('/mobile/user/getsmscode');
                this.smstext = '已发送';
            }
        }
    });
</script>